package com.goods.business.converter;

import com.goods.business.service.HealthService;
import com.goods.common.model.business.Health;
import com.goods.common.response.ResponseBean;
import com.goods.common.utils.ListPageUtils;
import com.goods.common.vo.system.PageVO;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "健康打卡")
@RestController
@RequestMapping("/business/health")
public class HealthController {

    @Autowired
    private HealthService healthService;



//    post("business/health/report",    健康报备成功  /business/health/report
    @PostMapping("/report")
    public ResponseBean report(@RequestBody Health health){
        healthService.report(health);
        return ResponseBean.success();
    }

    //今日健康报备检查  get("business/health/isReport")
    @GetMapping("/isReport")
    public ResponseBean isreport(){
        Boolean isToday = healthService.isToday();
        return ResponseBean.success(isToday);
    }
    //历史记录获取  business/health/history   pageSize=4&pageNum=1
    @GetMapping("/history")
    public ResponseBean history(Integer pageSize,Integer pageNum){
        List<Health> healthList = healthService.history();
        List<Health> page = ListPageUtils.page(healthList, pageSize, pageNum);
        PageVO<Health> objectPageVO = new PageVO<>(healthList.size(),page);
        return ResponseBean.success(objectPageVO);
    }


}
